/*  
 *  @author Philip Stutz
 * 
 *  Copyright 2011 University of Zurich
 *      
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *  
 *         http://www.apache.org/licenses/LICENSE-2.0
 *  
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package ch.uzh.ifi.ddis.ds2011.a3.helper;

import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;

/**
 * The class CollectionBuilder initializes instances of collections.
 */
public class CollectionBuilder {

	/**
	 * Creates a new set containing `setItems`.
	 * 
	 * @param <G>
	 *            the set element type
	 * @param setItems
	 *            the set items
	 * @return a new set that contains `setItems`
	 */
	public static <G> Set<G> newSet(G... setItems) {
		HashSet<G> result = new HashSet<G>();
		for (G setItem : setItems) {
			result.add(setItem);
		}
		return result;
	}

	/**
	 * Creates a new list containing `listItems`.
	 * 
	 * @param <G>
	 *            the list element type
	 * @param listItems
	 *            the list items
	 * @return a new list that contains `listItems`
	 */
	public static <G> List<G> newList(G... listItems) {
		LinkedList<G> result = new LinkedList<G>();
		for (G listItem : listItems) {
			result.add(listItem);
		}
		return result;
	}

}
